<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/HomeTemplate.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                >
    <ui:define name="body">
        
        <div class="main-container" >
        
        <h:form>
            <p:panelGrid columns="2">
                <p:column>
        <p:panelMenu style="width:200px; text-align: left">
            <p:submenu label="Dealers" >
                <p:menuitem value="Inventory Managment" icon="ui-icon-bullet" />
            
        </p:submenu>
        <p:submenu label="Order">
            <p:menuitem value="Brand Managment "  icon="ui-icon-bullet" url="AdminParametricBrand.xhtml"/>
            <p:menuitem value="Product Type Managment "  icon="ui-icon-bullet" url="AdminParametricProduct.xhtml" />
            <p:menuitem value="Category Managment"   icon="ui-icon-bullet" url="AdminParametricCategory.xhtml"/>
            <p:menuitem value="Catalog Managment"  icon="ui-icon-bullet" url="AdminParametricCatalog.xhtml"/>
            <p:menuitem value="Inventory Managment"  icon="ui-icon-bullet" url="AdminParametricInventory.xhtml"/>
        </p:submenu>
         <p:submenu label="Account">
            <p:menuitem value="Delete"   icon="ui-icon-bullet"/>
        </p:submenu>
        <p:submenu label="Warranty" >
            <p:submenu label="Links" icon="ui-icon-bullet">
                <p:submenu label="PrimeFaces" icon="ui-icon-bullet">
                    <p:menuitem value="Home" url="http://www.primefaces.org" icon="ui-icon-bullet" />
                </p:submenu>
            </p:submenu>
            <p:menuitem value="Mobile" icon="ui-icon-bullet" />
        </p:submenu>
        <p:submenu label="Marketing">
            <p:menuitem value="Save" icon="ui-icon-bullet" />
            
        </p:submenu>
       
        
    </p:panelMenu>
             </p:column>  
                <p:column>
  <p:growl id="growl" showDetail="true"/>  
            <p:growl id="msgs" showDetail="true" />
             
                <p:dataTable id="dataTable" var="inventory" value="#{orderBean.inventories}" widgetVar="inventoryTable" paginator="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks}
                             {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" paginatorPosition="bottom" editable="true" editMode="cell"
                             rows="10" rowsPerPageTemplate="10,20,40" filteredValue="#{orderBean.filterInventory}"
                             > 
                <f:facet name="header">
                    Inventory
                </f:facet>
                <p:ajax event="rowSelect" listener="#{opCenBean.onRowSelect}" update=":#{p:component('msgs')}"  />
                <p:ajax event="rowUnselect" listener="#{opCenBean.onRowUnselect}" update=":#{p:component('msgs')}" />
                <p:column filterBy="#{inventory.sku}" filterMatchMode="contains">  
                    <f:facet name="header">  
                            GI SKU 
                        </f:facet>  

                        <h:outputText value="#{inventory.sku}" />  

                    </p:column> 
                    <p:column headerText="Picture" >  

                        <h:outputLink value="#{inventory.catalog.link}" target="_blank">
                            <img src="#{request.contextPath}/resources/img/icons/#{inventory.classDesc}.jpg"   />
                        </h:outputLink>
                    </p:column>

                <p:column headerText="Model Name" filterBy="#{inventory.modelName}" >  
                        <h:outputText value="#{inventory.modelName}" style="float: left"/>  
                    </p:column> 
                <p:column headerText="Model Year" filterBy="#{inventory.modelYear}">  
                        <h:outputText value="#{inventory.modelYear}" />  
                    </p:column> 

                    <p:column headerText="Size" >  
                        <h:outputText value="#{inventory.sizeDesc}" />  
                    </p:column>  
                    
                    <p:column headerText="Color" >  
                        <h:outputText value="#{inventory.colorDesc}" />  
                    </p:column> 

                    <p:column headerText="Price ($)">  
                        <h:outputText value="#{inventory.grossPrice}" style="text-align: center" >
                            <f:convertNumber type="currency"  currencySymbol="" pattern="###,###" />
                        </h:outputText>  
                    </p:column> 

                <p:column headerText="Available" filterBy="#{inventory.isAvailable}">  
                     <f:facet name="filter">
                 
                     </f:facet>
                        <h:outputText value="#{inventory.isAvailable}" />  
                    </p:column>  


                <f:facet name="footer">  
                    In total there are #{orderBean.inventories.size()} Items.  
                </f:facet>  

            </p:dataTable> 
             <h:panelGrid id="buttons" columns="5" cellpadding="4" style="border-bottom-width: 30px"> 
                <p:commandButton  value="Add" onclick="panelwv.show();"  type="button" > </p:commandButton> 
                <p:commandButton  value="Update" onclick="panelwv.show();" type="button"> </p:commandButton> 
                <p:commandButton  value="Remove"  > </p:commandButton>   
                <p:commandButton  value="Excel" action="#{reporteController.submit()}" immediate="true" ajax="false"> </p:commandButton>  
            </h:panelGrid>

            <p:panel id="editPanel" header="Add" widgetVar="panelwv" visible="false" style="width: 70%;">  

                <h:panelGrid id="editGrid" columns="3">  
                    <h:outputText value="SKU : *" /> 
                    <p:selectOneMenu id="curr" required="true" value="#{opCenBean.opCen.idTypeCurrency}" converter="#{typeCurrencyConverter}" style="width: 228px;">  
                        <f:selectItem itemLabel="Select Type Currency" itemValue="" />  
                        <f:selectItems value="#{typeCurrencyBean.typeCurrencys}" var="typeCurrency" itemLabel="#{typeCurrency.description}" itemValue="#{typeCurrency}"/>  
                    </p:selectOneMenu> 
                    <p:message id="defaultMessage" for="curr" />   

                    <h:outputText value="Cen Op Name: *" />   
                    <p:inputText id="nam" value="#{opCenBean.opCen.name}" required="true" label="Name"/>  
                    <p:message id="textOnlyMessage" for="nam" display="text" />  

                    <h:outputText value="Cen Op Description: *" />   
                    <p:inputText id="desc" value="#{opCenBean.opCen.description}" required="true" label="Description"/> 
                    <p:message id="textOnlyMessage2" for="desc" display="text" />  

                </h:panelGrid>  

                <p:commandButton value="Save" actionListener="#{opCenBean.saveOpCen()}" update="dataTable" ajax="false"/>

                <p:commandButton value="Cancel" update="editPanel" process="@this" actionListener="#{opCenBean.resetFail}"/>

            </p:panel>  

            </p:column>
</p:panelGrid>
</h:form>
  </div>
    </ui:define>
</ui:composition>

